<template>
  <div>
    <BaseTable
      ref="billRecordTable"
      height="200"
      @chaneg-size="changeLogSizeHandle"
      @chaneg-page="changeLogPageHandle">
      <el-table-column align="center" label="序号" width="50" type="index" />
      <el-table-column align="center" prop="OP_DATE" label="操作时间" min-width="50" />
      <el-table-column align="center" prop="OP_TYPE" label="操作类型" min-width="50" >
        <template slot-scope="scope">
          <filtercode v-model="scope.row.OP_TYPE" :type="scope.row.TYPE" />
        </template>
      </el-table-column>
      <el-table-column align="center" prop="OP_BY_NAME" label="操作人" min-width="50" />
      <!--      <el-table-column :show-overflow-tooltip="true" align="center" prop="OP_DESC" label="操作描述" />-->
      <el-table-column :show-overflow-tooltip="true" align="center" prop="OP_REMARK" label="操作描述" />
    </BaseTable>
  </div>
</template>
<script>
import BaseTable from '@/components/BaseTable'
import filtercode from '@/components/Checkbox/filtercode'
import {
  queryBillRecordInfo
} from '@/api/vehicleBaseData/billrecord/BillRecord'

export default {
  name: 'BillRecordTable',
  components: {
    BaseTable,
    filtercode
  },

  props: {
    billType: {
      type: String,
      required: true
    },
    billId: {
      type: String,
      required: true
    },
    optype: {
      type: Number,
      required: false
    }
  },
  data() {
    return {
      type: 3021,
      search: {
        limit: 10,
        pageNum: 1
      }
    }
  },
  watch: {
    billId(newValue, oldvalue) {
      if (newValue !== oldvalue) {
        this.searchBillRecordInfo()
      }
    }
  },
  mounted() {
    if (this.billId != null) {
      this.searchBillRecordInfo()
    }
    if (this.optype != null) {
      this.type = this.optype
    }
  },
  methods: {
    searchBillRecordInfo() {
      // 查询操作日志
      const table = this.$refs['billRecordTable']
      table.wait()
      queryBillRecordInfo(Object.assign({}, { BILL_TYPE: this.billType, BILL_ID: this.billId }, this.search)).then(res => {
        table.complete().filData(res)
      })

      return this
    },
    // 改变当前也显示数目
    changeLogSizeHandle(table, size) {
      this.search.limit = size
      this.searchBillRecordInfo && this.searchBillRecordInfo()

      return this
    },
    // 改变页数
    changeLogPageHandle(table, num) {
      this.search.pageNum = num
      this.searchBillRecordInfo && this.searchBillRecordInfo()

      return this
    }
  }
}
</script>>
